/**
 * Copyright © 2021-2025 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.organization.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeeplus.organization.domain.OfficeRequest;
import com.jeeplus.organization.mapper.OfficeRequestMapper;
import com.jeeplus.organization.service.dto.BossDTO;
import com.jeeplus.organization.service.dto.OfficeRequestDTO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 请示稿件Service
 * @author 淋漓
 * @version 2024-06-16
 */
@Service
@Transactional
public class OfficeRequestService extends ServiceImpl<OfficeRequestMapper, OfficeRequest> {
    public List<BossDTO> selectPostById(String id){
        return baseMapper.selectByPostId(id);
    }
    public IPage<OfficeRequestDTO> MyPage(Page<OfficeRequestDTO> page,String userName,String approverId,String userId, String status,String title){
        return baseMapper.MyPage(page,userName,approverId,userId,status,title);
    }

    public OfficeRequestDTO SelectById(String id){
        return baseMapper.SelectById(id);
    }
    public String getFileName(List<OfficeRequest> list){
        String[] strings = new String[10];
        int[] ints = new int[10];
        //初始化
        for (int i=0;i<10;i++){
            strings[i]=i+1+"";
            ints[i]=0;
        }
        for (OfficeRequest officeRequest :list) {
            for(int j=0;j<10;j++){
                if(officeRequest.getName().contains(strings[j])){
                    ints[j]=1;
                    break;
                }
            }
        }
        for (int i=0;i<10;i++){
            if(ints[i]==0){
                return "未命名"+i+1;
            }
        }
        return  "未命名666";
    }
}
